package code;

public class UDP {
	public double rate_; // transmission rate pkts/s
	Node source_, dest_;
	double starttime_,endtime_;

	public UDP() {
		this.rate_ = 0;
		this.starttime_=0.1;
		this.endtime_=Global.ENDTIME;
	}


	public UDP(double rate_, Node source_, Node dest_, double starttime_,
			double endtime_) {
		this.rate_ = rate_;
		this.source_ = source_;
		this.dest_ = dest_;
		this.starttime_ = starttime_;
		this.endtime_ = endtime_;
		Event e=new Event();
		e.action_=2;
		e.timer_=starttime_;
		e.udp_=this;
		Global.EVENTQUEUE.putinqueue_(e);	
		System.out.println("UDP Generation Complete");
	}


	void generate_traffic_() {
		Event e=new Event();
		e.action_=2;
		e.timer_=1/rate_+Global.TIME;
		e.udp_=this;
		Global.EVENTQUEUE.putinqueue_(e);
		Packet p = new Packet();
		p.m_category_=1;
		p.m_dest_=dest_;
		p.m_destIP_=dest_.IPadd_;
		p.m_size_=Global.DATASIZE;
		p.m_source_=source_;
		p.m_sourceIP_=source_.IPadd_;
		p.m_pkt_generationtime_=Global.TIME;
		source_.get_pkt_(p);
	}
}
